package controllers

import (
	"github.com/astaxie/beego"
	//"fmt"
    
	"beego/testApp/common/class"
	"beego/testApp/common/tool"
	"time"
)

type AddClassController struct {
	beego.Controller
}

func (c *AddClassController) Get() {

	cname   := c.GetString("cname")
	tname   := c.GetString("tname")
	cnum    := c.GetString("cnum")
	cnumint := tool.XtoInt(cnum)

	if(cname !="" && tname !="" && cnum!=""){

		 class := &class.Class{Cid:0,Cname:cname,Tname:tname,Cnum:cnumint,Created:time.Now()}
		 addre := class.AddClass();

		 if(addre == true){
			 c.Redirect("/admin/classlist",301)
		 }

	}

	c.Data["Website"] = "beego.me"
	c.Data["Email"] = "astaxie@gmail.com"
	c.TplName = "addclass.html"

}
